use strict;
use warnings;

use Dogtanian;
use File::Basename;

command list => sub {
	my @files = <${Dogtanian::plugin_dir}/*>;
	my @suffixes = ('.pl');
	my @plugins = map { scalar fileparse($_, @suffixes); } @files;
	my $listing = join ', ', @plugins;
	say("available plugins: $listing");
};

command load => sub {
	my $plugin_name = shift;
	say("loading plugin $plugin_name...");
	Dogtanian::load($plugin_name);
	say("loaded $plugin_name successfully");
};

command unload => sub {
	my $plugin_name = shift;
	say("unloading plugin $plugin_name...");
	Dogtanian::unload($plugin_name);
	say("detached $plugin_name successfully");
};

command commands => sub {
	my @commands = keys %Dogtanian::commands;
	say("available commands are: " . join(', ', @commands));
};
